package com.cskaoyan.service;

import com.cskaoyan.dao.UserDao;
import com.cskaoyan.dao.UserDaoImpl;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @author stone
 * @date 2022/06/16 10:17
 */
@Component
public class UserServiceImpl implements UserService{
    UserDao userDao; // = new UserDaoImpl();

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    // 会覆盖掉默认的无参构造方法，会采用有参构造方法来完成实例化
    // 形参默认按照类型从容器中取出组件 → 如果想要指定组件id → @Qualifier
    public UserServiceImpl(@Qualifier("userDaoImpl") UserDao userDao) {
        this.userDao = userDao;
    }
}
